package com.example.seckill.controller;

import com.example.seckill.service.IUserService;
import com.example.seckill.vo.LoginVo;
import com.example.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

/**
 * @program: seckill
 * @description: 登录功能
 * @author: KingCrimson
 * @create: 2022-08-06 20:13
 **/



@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    private IUserService userService;

    /**
    * @Description: 跳转登录页面
    * @Param:
    * @return:
    * @Author: KingCrimson
    * @Date: 2022/8/6
    */
    @RequestMapping("/toLogin")
    public String toLogin(){
        return "login";
    }

    /**
    * @Description: 登录功能
    * @Param: 
    * @return: 
    * @Author: KingCrimson
    * @Date: 2022/8/6
    */
    @RequestMapping("/doLogin")
    @ResponseBody
    public RespBean doLogin(@Valid LoginVo loginVo, HttpServletRequest request, HttpServletResponse response){
        return userService.doLogin(loginVo,request,response);
    }

}
